﻿CREATE TABLE [dbo].[ContactPerson] (
    [Id]           INT              IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
    [CustomerId]   UNIQUEIDENTIFIER NULL,
    [PersonId]     UNIQUEIDENTIFIER CONSTRAINT [DF_ContactPerson_PersonId] DEFAULT (newid()) NULL,
    [ZName]        NVARCHAR (50)    NULL,
    [Sex]          NVARCHAR (10)    NULL,
    [Position]     NVARCHAR (50)    NULL,
    [OfficeTel]    NVARCHAR (50)    NULL,
    [HomeTel]      NVARCHAR (50)    NULL,
    [Mobile]       NVARCHAR (50)    NULL,
    [Email]        NVARCHAR (50)    NULL,
    [CreateDate]   DATETIME         CONSTRAINT [DF_ContactPerson_CreateDate] DEFAULT (getdate()) NULL,
    [IsMain]       BIT              NULL,
    [PersonTypeId] INT              CONSTRAINT [DF_ContactPerson_PersonTypeId] DEFAULT ((0)) NULL,
    [Age]          INT              NULL,
    [Weixin]       NVARCHAR (50)    NULL,
    CONSTRAINT [PK_ContactPerson] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 90)
);


GO
CREATE NONCLUSTERED INDEX [IX_ContactPerson_CustomerId]
    ON [dbo].[ContactPerson]([CustomerId] ASC) WITH (FILLFACTOR = 90);


GO
CREATE NONCLUSTERED INDEX [IX_ContactPerson_Mobile]
    ON [dbo].[ContactPerson]([Mobile] ASC) WITH (FILLFACTOR = 90);


GO
CREATE NONCLUSTERED INDEX [IX_ContactPerson_OfficeTel]
    ON [dbo].[ContactPerson]([OfficeTel] ASC) WITH (FILLFACTOR = 90);


GO
CREATE NONCLUSTERED INDEX [IX_ContactPerson_HomeTel]
    ON [dbo].[ContactPerson]([HomeTel] ASC) WITH (FILLFACTOR = 90);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_ContactPerson_f7fa02a52d9b47989a60bef555d98829]
    ON [dbo].[ContactPerson]([PersonId] ASC) WITH (FILLFACTOR = 90);


GO


-- =============================================
-- Author:		<王鑫鹏>
-- Create date: <2011-03-24>
-- Description:	<删除客户触发器>
-- =============================================
Create TRIGGER [ContactPerson_Deleted] On [dbo].[ContactPerson]
AFTER DELETE
AS 
BEGIN
	Insert Into Recycler_ContactPerson Select * From Deleted
END


